package com.smartcruise.util.network.customerObserver;

import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;

import retrofit2.HttpException;


/**
 * Created by FengChaoQun
 * on 2017/8/26 0026
 * 对服务器返回的异常进行判断
 */

public class NetErrorUtils {

    public static String getErrorNotice(Throwable e) {
        if (e instanceof SocketTimeoutException) {
            return "请求超时";
        } else if (e instanceof ConnectException) {
            return "无法连接到服务器，请检查您的网络状态";
        } else if (e instanceof HttpException) {
            return "服务器异常";
        } else if (e instanceof UnknownHostException) {
            return "无法连接到服务器，请检查您的网络状态";
        } else {
            return "网络请求出现异常:" + e.getMessage();
        }
    }

}
